import {Component, Input, OnInit} from '@angular/core';
import {CommonService} from "../../service/base/common.service";
import {NzModalRef, NzModalService} from "ng-zorro-antd/modal";
import {AdminListHttpService} from "../../service/http/admin.list.http.service";
import {NzMessageService} from "ng-zorro-antd/message";
import {HttpCustomConfig} from "../../service/base/base.http.service";
import {UserHttpService} from "../../service/http/user.http.service";

@Component({
  selector: 'app-user-detail',
  templateUrl: './user-detail.component.html',
  styleUrls: ['./user-detail.component.less']
})
export class UserDetailComponent implements OnInit {

  userId: number = 0;
  memo: string = '';
  userRate: number = 0.08;
  cpsTo: string = 'zmrs'
  cpsToList = [
    {value: 'zmrs', label: '中免日上'}];
  cpsEp: string = 'iskytrip';
  cpsEpList = [
    {value: 'iskytrip', label: '在机场'},
    {value: '55', label: '55海淘'}];

  constructor(private commonService: CommonService,
              private userHttpService: UserHttpService,
              private modalRef: NzModalRef) {
  }

  defaultHttpConfig: HttpCustomConfig = {showLoading: false}

  ngOnInit(): void {

  }

  handleConfirm(): void {
    this.userHttpService.addUserCps({
      memo: this.memo,
      userId: this.userId,
      cpsTo: this.cpsTo,
      cpsEp: this.cpsEp,
      userRate: this.userRate
    }, this.defaultHttpConfig).subscribe((res) => {
      this.commonService.toast('保存成功');
      this.modalRef.destroy()
    })
  }
}
